/*=============================================================
(c) 2012 by Juliano Efson Sales
www.mdcc.ufc.br
================================================================*/

using System.Collections;

namespace HPE.Load{
   public class Identifier {
      
      public string component;
      
      public string unit;
      
      public string method;
      
      public static Identifier getIdentifier(string name, Hashtable aliasHash) {
         Identifier id = new Identifier();
         
         string pivot = name.Substring(0, name.IndexOf('.'));
         string alias = (string) aliasHash[pivot];
         
         if(alias != null && !alias.Equals("")) {
            id.component = alias.Substring(0, alias.IndexOf("."));
            id.unit = alias.Substring(alias.IndexOf(".")+1);

         } else {
            id.component = pivot;
            id.unit = name.Substring(name.IndexOf(".")+1, name.LastIndexOf('.')-name.IndexOf(".")-1);

         }
         
         id.method = name.Substring(name.LastIndexOf('.')+1);
         
         return id;
      }
      
      public string toString() {
         return "Component: " + component + "| unit: " + unit + "| method: " + method;
      }
   }
}
